-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement multi-schema support #727
base: main
Are you sure you want to change the base?
Implement multi-schema support #727
Conversation
src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java
Outdated
Show resolved
Hide resolved
7effe3b
to
0385016
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
Besides the minor comment I posted this looks good to me. Thank you, @philipp-kleber-avelios for contributing with this PR.
Daniel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@philipp-kleber-avelios Why getConnectionCatalogName()
and getConnectionSchemaName()
are being locked here to constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For getConnectionCatalogName()
, the behavior is the same as before just without one less indirection (it used to call getDefaultCatalogName()
internally).
For getConnectionSchemaName()
, the behavior is slightly different from before:
It used to call getDefaultSchemaName()
internally, but we can't do this anymore: The new getDefaultSchemaName()
implementation calls super.getDefaultSchemaName()
and this then calls getConnectionSchemaName()
, so we'd have a call-cycle.
@@ -34,6 +34,12 @@ protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) thro | |||
Schema schema = (Schema) foundObject; | |||
HibernateDatabase database = (HibernateDatabase) snapshot.getDatabase(); | |||
for (org.hibernate.boot.model.relational.Namespace namespace : database.getMetadata().getDatabase().getNamespaces()) { | |||
boolean namespaceMatchesSchema = (namespace.getName().getSchema() != null && namespace.getName().getSchema().matches(foundObject.getName())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is duplicated in SequenceSnapshotGenerator
and TableSnapshotGenerator
. Could you extract it to a generic method in HibernateSnapshotGenerator
, or even move the check there so it's not repeated? As I believe it would be necessary to IndexSnapshotGenerator
and other SnapshotGenerators
too.. or am I overreacting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can extract the check. I don't think we need to move the check though, since from my understanding, DatabaseObjects
other than Schema
, Table
and Sequence
are added only from those three corresponding snapshot-generators.
So I think if we have the check in those three generators, we don't need the check in the other ones, since the database objects that get to them always already have the correct schema.
I might be wrong though, I don't fully understand the snapshotting mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
These changes are an initial experiment to resolve issue #248, by allowing multiple schemas during the snapshot.
I added a new test
HibernateMultiSchemaTest.java
, which currently only checks the exit code of such a multi-schemadiffChangelog
command.If somebody could review the code and maybe give their input if the changes are sufficient or if additional ones are required, that would be great, thanks!.